server:
  port: {{port}}
  servlet:
    context-path: {{contextPath}}

spring:
  application:
    name: {{applicationName}}
  
  # 数据源配置
  datasource:
    type: {{#if enableDruid}}com.alibaba.druid.pool.DruidDataSource{{else}}com.zaxxer.hikari.HikariDataSource{{/if}}
    driver-class-name: {{databaseConfig.driverClassName}}
    url: {{databaseConfig.url}}
    username: {{databaseConfig.username}}
    password: {{databaseConfig.password}}
    {{#if enableDruid}}
    druid:
      # 初始连接数
      initialSize: {{druidConfig.initialSize}}
      # 最小连接池数量
      minIdle: {{druidConfig.minIdle}}
      # 最大连接池数量
      maxActive: {{druidConfig.maxActive}}
      # 配置获取连接等待超时的时间
      maxWait: {{druidConfig.maxWait}}
      # 配置间隔多久才进行一次检测，检测需要关闭的空闲连接，单位是毫秒
      timeBetweenEvictionRunsMillis: {{druidConfig.timeBetweenEvictionRunsMillis}}
      # 配置一个连接在池中最小生存的时间，单位是毫秒
      minEvictableIdleTimeMillis: {{druidConfig.minEvictableIdleTimeMillis}}
      # 配置一个连接在池中最大生存的时间，单位是毫秒
      maxEvictableIdleTimeMillis: {{druidConfig.maxEvictableIdleTimeMillis}}
      # 配置检测连接是否有效
      validationQuery: SELECT 1 FROM DUAL
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      # 配置监控统计拦截的filters，去掉后监控界面sql无法统计，'wall'用于防火墙
      filters: stat,wall
      # 通过connectProperties属性来打开mergeSql功能；慢SQL记录
      connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\={{druidConfig.slowSqlMillis}}
      # 配置DruidStatFilter
      web-stat-filter:
        enabled: true
        url-pattern: "/*"
        exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
      # 配置DruidStatViewServlet
      stat-view-servlet:
        enabled: true
        url-pattern: "/druid/*"
        # IP白名单(没有配置或者为空，则允许所有访问)
        allow: {{druidConfig.allow}}
        # IP黑名单 (存在共同时，deny优先于allow)
        deny: {{druidConfig.deny}}
        # 禁用HTML页面上的"Reset All"功能
        reset-enable: false
        # 登录名
        login-username: {{druidConfig.loginUsername}}
        # 登录密码
        login-password: {{druidConfig.loginPassword}}
    {{/if}}

  {{#if enableRedis}}
  # Redis配置
  redis:
    host: {{redisConfig.host}}
    port: {{redisConfig.port}}
    password: {{redisConfig.password}}
    database: {{redisConfig.database}}
    timeout: {{redisConfig.timeout}}
    lettuce:
      pool:
        max-active: {{redisConfig.maxActive}}
        max-wait: {{redisConfig.maxWait}}
        max-idle: {{redisConfig.maxIdle}}
        min-idle: {{redisConfig.minIdle}}
  {{/if}}

  # Jackson配置
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8
    serialization:
      write-dates-as-timestamps: false
    deserialization:
      fail-on-unknown-properties: false

# MyBatis Plus 配置
mybatis-plus:
  # 配置mapper的扫描，找到所有的mapper.xml映射文件
  mapper-locations: classpath*:/mapper/**/*.xml
  # 搜索指定包别名
  type-aliases-package: {{basePackage}}.entity
  configuration:
    # 开启驼峰命名
    map-underscore-to-camel-case: true
    # 配置JdbcTypeForNull
    jdbc-type-for-null: 'null'
    # 开启缓存
    cache-enabled: true
    {{#if enableSqlLog}}
    # 打印sql
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    {{/if}}
  global-config:
    db-config:
      # 主键类型
      id-type: {{mybatisConfig.idType}}
      # 字段策略
      field-strategy: {{mybatisConfig.fieldStrategy}}
      {{#if mybatisConfig.enableLogicDelete}}
      # 逻辑删除字段
      logic-delete-field: {{mybatisConfig.logicDeleteField}}
      # 逻辑删除值
      logic-delete-value: {{mybatisConfig.logicDeleteValue}}
      # 逻辑未删除值
      logic-not-delete-value: {{mybatisConfig.logicNotDeleteValue}}
      {{/if}}
      # 数据库表前缀
      table-prefix: {{mybatisConfig.tablePrefix}}
    banner: false

{{#if enablePageHelper}}
# PageHelper分页插件
pagehelper:
  helperDialect: mysql
  reasonable: true
  supportMethodsArguments: true
  params: count=countSql
{{/if}}

# Knife4j配置
knife4j:
  enable: true
  setting:
    language: zh_cn
  production: false

# SpringDoc配置
springdoc:
  swagger-ui:
    path: /swagger-ui.html
    enabled: true
  api-docs:
    path: /v3/api-docs
    enabled: true
  group-configs:
    - group: '{{projectName}} API'
      paths-to-match: '/api/**'
      packages-to-scan: {{basePackage}}.controller

{{#if enableSecurity}}
# Spring Security配置
security:
  jwt:
    secret: {{jwtConfig.secret}}
    expiration: {{jwtConfig.expiration}} # 24小时
    refresh-expiration: {{jwtConfig.refreshExpiration}} # 7天
{{/if}}

# 日志配置
logging:
  level:
    {{basePackage}}: {{logLevel}}
    {{basePackage}}.mapper: {{sqlLogLevel}}
    {{#if enableSecurity}}
    org.springframework.security: {{securityLogLevel}}
    {{/if}}
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n"
    file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n"
  file:
    name: logs/{{artifactId}}.log
    max-size: {{logConfig.maxSize}}
    max-history: {{logConfig.maxHistory}}

{{#if enableActuator}}
# 监控端点配置
management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: always
  info:
    git:
      mode: full
{{/if}}

# 应用信息
info:
  app:
    name: ${spring.application.name}
    description: {{description}}
    version: {{version}}
    author: {{author}}
    contact:
      email: {{authorEmail}}
      url: {{authorUrl}}

# 自定义配置
app:
  {{#if enableFileUpload}}
  # 文件上传配置
  upload:
    path: {{uploadConfig.path}}
    max-file-size: {{uploadConfig.maxFileSize}}
    max-request-size: {{uploadConfig.maxRequestSize}}
    allowed-extensions: {{uploadConfig.allowedExtensions}}
  {{/if}}
  
  # 代码生成配置
  generator:
    template-path: {{generatorConfig.templatePath}}
    output-path: {{generatorConfig.outputPath}}
    author: {{author}}
    package-name: {{basePackage}}
    
  # 系统配置
  system:
    name: {{projectName}}
    version: {{version}}
    copyright: Copyright © {{currentYear}} {{projectName}}
    support-email: {{authorEmail}}
